<template>
	<el-form  :model="planform" label-width="80px">
	
		<el-form-item label="病人号">
			<el-input v-model="planform.patientId"></el-input>
		</el-form-item>
		<el-form-item label="病因">
			<el-input v-model="planform.diseaseCause"></el-input>
		</el-form-item>
		<el-form-item label="治疗处方">
			<el-input v-model="planform.prescription"></el-input>
		</el-form-item>
		<el-form-item label="主治医生">
			<el-input v-model="planform.physician"></el-input>
		</el-form-item>
		<el-form-item label="治疗医师">
			<el-input v-model="planform.therapist"></el-input>
		</el-form-item>
		<el-form-item label="开始时间">
			<el-input v-model="planform.starttime"></el-input>
		</el-form-item>
		<el-form-item label="治疗周期">
			<el-input v-model="planform.recoveryCycle"></el-input>
		</el-form-item>
		<el-button type="primary" @click="doPlanEdit">提交</el-button>
	</el-form>

</template>

<script>
	export default{
		name:'PlanEdit',
		props:{
			formData:{
				type:Object,
				default:()=>({})
			},
			editVisible:{
				type:Boolean,
			}
		},
		data(){
			return{
				planform:{
					patientId:'',
					diseaseCause:'',
					prescription:'',
					physician:'',
					therapist:'',
					starttime:'',
					recoveryCycle:''
				}
			}
		},
		mounted(){
			this.planform=this.formData;
			console.log("子组件数据:");
			console.log(this.planform)
		},
		methods:{
			doPlanEdit(){
				this.postRequest("/recovery/update",this.planform).then(resp=>{
					if(resp){
						this.$emit("update:editVisible",false);
					}else{
						this.$message.error({message:'编辑失败'});
					}
				})
			}
		},
		watch:{
			formData:{
				deep:true,
				handler(newVal,oldVal){
					this.planform=newVal
				}
			}
		}
	}
</script>

<style>
</style>
